////<!--盘点明细-->
import api from '../../../fetch/api'

export default {
  data() {
    return {
      bigImgPath: ''
    }
	},
  created() {
    // this.getItemList();
    this.initSearch();
  },
  methods: {
    getList() {
      let params = $.extend({}, this.searchParams, this.otherParams);
      this.getItemList(params);
    },
    showBigImgModal(name, path) {
      this.bigImgPath = path;
      this.toOpenImgModal(name, path);
    },
    //获取列表
    getItemList(aparams) {
      let self = this;
      let setData = {};
      let params = {
        page: self.pageNumber,
        pageSize: self.pageSize
      };

      if (this.setData && this.ones) {
        this.setData.searchList.forEach(element => {
          if (element.name == "query_time_up" && element.value != '') {
            setData["reportTimeFrom"] = element.value.split(" - ")[0];
            setData["reportTimeTo"] = element.value.split(" - ")[1];
          } else if ("query_time_pandian" == element.name && element.value != '') {
            setData["checkTimeFrom"] = element.value.split(" - ")[0];
            setData["checkTimeTo"] = element.value.split(" - ")[1];
          } else {
            setData[element.name] = element.value;
          }
        });
      }
      params = $.extend(setData, params, aparams);
      this.ones = null;
      api.fetchGet('mobile/parkingCheck/detail/list.do', params)
        .then(res => {
          let data = res.data;
          self.tbodysInfo = data.rows;
          self.total = data.total;
        }, err => {})
    },
    initSearch() {
      if (this.setData) {
        this.searchList.forEach(element => {
          this.setData.searchList.forEach(elementPar => {
            if (element.name == elementPar.name) {
              if (element.name == "query_time_up" || element.name == "query_time_pandian") {
                if (elementPar.value != '') {
                  let today = [
                    new Date(moment().format(elementPar.value.split(" - ")[0])),
                    new Date(moment().format(elementPar.value.split(" - ")[1]))
                  ];
                  element.value = today;
                } else {
                  element.value = '';
                }
              } else {
                element.value = elementPar.value
              }
            }
          });
        });
      }
    },
    exportData() {
      let self = this;
      let theadsArr = []
      for(let i = 0; i<self.theadsInfo.length; i++){
        if(self.theadsInfo[i].checked){
          theadsArr.push(self.theadsInfo[i].prop)
        }
      }
      let params = {
        meterList: theadsArr.join(',')
      };
      params = $.extend({}, params, self.searchParams, self.otherParams);
      self.showDialog("确认导出该报表?", '', function () {
        self.toExportAsync('mobile/parkingCheck/detail/export.do', params);
      });
    }
  }
}
